<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>   
    <div id="backi" class="fllow">
<ul>
<li class="" onMouseOver="this.className='over'" onMouseOut="this.className=''"><a href="#myModal" title="创建一个话题" role="button" data-toggle="modal"><i class="icon-edit"></i></a></li>
<li class="" onMouseOver="this.className='over'" onMouseOut="this.className=''"><a href="#topIndex"><i class="icon-arrow-up"></i></a></li>
</ul>
</div>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel"><i class="icon-file-text-alt"></i><font id="launchMenuName"></font>新问题</h3>
  </div>
  
  <div class="modal-body">
	<div>标题:<input style="width:99%; height: 30px;" type="text" id="launchTopicTitle" name-="vo.topicVo.title" value=""/></div>
  <div>内容
    <textarea name="vo.topicVo.subjectInfo" id = "launchSubjectInfo"  rows="5" style="width:99%;height: 300px;" data-provide="typeahead"></textarea>
</div>
                        
  </div>
  <div class="modal-footer">
    <button class="btn btn-primary btn-default" id="launchCloseBtn" data-dismiss="modal" aria-hidden="true">关闭</button>
    <button class="btn btn-primary" onclick="launchTopic();"> <i class="icon-mail-forward"></i> 提交  </button>Ctrl+Enter
  </div>
</div>
    
<script charset="utf-8" src="${pageContext.request.contextPath}/js/kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="${pageContext.request.contextPath}/js/kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="${pageContext.request.contextPath}/js/kindeditor/plugins/code/prettify.js"></script>
	<script>
	
	function launchTopic(){
		var title = $("#launchTopicTitle").val();
		var launchSubjectInfo =  $.trim(launchTopicEditor.html());
		if($.trim(title)==''){
			alert('请填写问题标题');
			return ;
		}else if($.trim(title).length<5){
			alert('你填写的问题标题太短了。');
			return ;
		}
		var mid = $("#mid").val();
		if(mid==''){
			alert('请选择功能再提问');
			return ;
		}
		
		//launchSubjectInfo =  $.trim(menuEditor.html());
	//	alert(launchSubjectInfo);
		
	//	var formData  = $('#search_form').serialize();
		var formData = {"vo.mid":mid,"vo.sysType":$("#sysType").val(),"vo.topicVo.title":title,"vo.topicVo.subjectInfo":launchSubjectInfo};
	//formData += "&vo.topicVo.title=" + title;
	//	formData += "&vo.topicVo.subjectInfo=" + launchSubjectInfo;
		$.ajax({
			type : 'post',
			cache : false,
			dataType : 'json',
			url : "${pageContext.request.contextPath}/help/topic/launchTopic.action",
			loading : '正在获取...',
			data : formData,
			success : function(msg) {
				alert(msg);
				$("#fourABtn").click();
				$("#launchCloseBtn").click();
				$("#launchTopicTitle").val('');
				launchTopicEditor.html('');
			},
			error : function(message) {
				alert("提交问题失败");
			}
		});
	}
	
	
	<c:if test="${vo.authority eq '1' }">	
	var menuEditor = "";
	</c:if>
	var launchTopicEditor = "";
	var chatEditor = "";
		KindEditor.ready(function(K) {
			
			<c:if test="${vo.authority eq '1' }">	
			 menuEditor = K.create('textarea[name="vo.menuDesc"]', {
				cssPath : '${pageContext.request.contextPath}/js/kindeditor/plugins/code/prettify.css',
				uploadJson : '${pageContext.request.contextPath}/kindEditor/uploadImg.action',
				allowFileManager : true,
				autoHeightMode : true,
				resizeType : 1,
				items : [
						 'bold', 'italic', 'underline',
						'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright',
						'insertunorderedlist', '|','emoticons']
				,
				afterCreate : function() {
					this.loadPlugin('autoheight');
					/*
					var self = this;
					
					K.ctrl(document, 13, function() {
						self.sync();
						updateMneuDesc();
					});  
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();alert(2);
						updateMneuDesc();
						
					});
					*/
				},
				
			});
			</c:if>
			launchTopicEditor = K.create('textarea[name="vo.topicVo.subjectInfo"]', {
				cssPath : '${pageContext.request.contextPath}/js/kindeditor/plugins/code/prettify.css',
				uploadJson : '${pageContext.request.contextPath}/kindEditor/uploadImg.action',
				allowFileManager : true,
				//autoHeightMode : true,
				resizeType : 0,
				items : [
						 'bold', 'italic', 'underline',
						'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright',
						'insertunorderedlist', '|', 'emoticons']
				,
				afterCreate : function() {
					//this.loadPlugin('autoheight');
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						launchTopic();
					});  
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						launchTopic();
					});
				},
				
			});
			chatEditor = K.create('textarea[name="vo.chatVo.sayInfo"]', {
				cssPath : '${pageContext.request.contextPath}/js/kindeditor/plugins/code/prettify.css',
				uploadJson : '${pageContext.request.contextPath}/kindEditor/uploadImg.action',
				allowFileManager : true,
				//autoHeightMode : true,
				resizeType : 0,
				items : [
						 'bold', 'italic', 'underline',
						'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright',
						'insertunorderedlist', '|', 'emoticons']
				,
				afterCreate : function() {
					//this.loadPlugin('autoheight');
					var self = this;
				},
				
			});
			
			prettyPrint();
		});
	</script>